package com.mobilepoc.jersey.storage;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.mobilepoc.jersey.model.TransactionDetail;

public class TransactionDetailStorage {
    private static final long ONE_DAY_IN_MS = 86400000L;

    private static List<TransactionDetail> details = new ArrayList<TransactionDetail>();

    static {
        TransactionDetail td1 = new TransactionDetail("5500444", new Date(), new Date(), "5500444-A", -250,
                "Icabutiken");
        TransactionDetail td2 = new TransactionDetail("5500445", new Date(new Date().getTime() - 2 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 2 * ONE_DAY_IN_MS), "5500445-A", -250, "Systembolaget");
        TransactionDetail td4 = new TransactionDetail("5500446", new Date(), new Date(new Date().getTime() - 4
                * ONE_DAY_IN_MS), "5500446-A", -1150, "Willys");
        TransactionDetail td3 = new TransactionDetail("5500447", new Date(new Date().getTime() - 5 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 5 * ONE_DAY_IN_MS), "5500447-A", -850, "Restaurangen");
        TransactionDetail td5 = new TransactionDetail("5500448", new Date(new Date().getTime() - 5 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 5 * ONE_DAY_IN_MS), "5500448-A", -2250, "Sportaffären");
        TransactionDetail td6 = new TransactionDetail("5500449", new Date(new Date().getTime() - 6 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 6 * ONE_DAY_IN_MS), "5500449-A", 32250, "Lön");
        TransactionDetail td7 = new TransactionDetail("5500450", new Date(new Date().getTime() - 7 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 7 * ONE_DAY_IN_MS), "55004410-A", -650, "Icabutiken");
        TransactionDetail td8 = new TransactionDetail("5500451", new Date(new Date().getTime() - 8 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 8 * ONE_DAY_IN_MS), "55004451-A", -50, "Kiosken");
        TransactionDetail td9 = new TransactionDetail("5500452", new Date(new Date().getTime() - 9 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 9 * ONE_DAY_IN_MS), "5500467867-A", -24, "Pressbyrån");
        TransactionDetail td10 = new TransactionDetail("5500453", new Date(new Date().getTime() - 9 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 10 * ONE_DAY_IN_MS), "5500442344-A", -250, "Icabutiken");
        TransactionDetail td11 = new TransactionDetail("5500454", new Date(new Date().getTime() - 10 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 11 * ONE_DAY_IN_MS), "5534334-A", -250, "Konsumbutiken");
        TransactionDetail td12 = new TransactionDetail("5500455", new Date(new Date().getTime() - 10 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 12 * ONE_DAY_IN_MS), "5534334-A", -246, "Icabutiken");
        TransactionDetail td13 = new TransactionDetail("5500456", new Date(new Date().getTime() - 11 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 12 * ONE_DAY_IN_MS), "5537764-A", -250, "Pablos Pannkakor");
        TransactionDetail td14 = new TransactionDetail("5500457", new Date(new Date().getTime() - 11 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 12 * ONE_DAY_IN_MS), "5537766-A", -1150, "Amazon");
        TransactionDetail td15 = new TransactionDetail("5500458", new Date(new Date().getTime() - 11 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 12 * ONE_DAY_IN_MS), "5537357-A", -398, "Icabutiken");
        TransactionDetail td16 = new TransactionDetail("5500459", new Date(new Date().getTime() - 11 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 12 * ONE_DAY_IN_MS), "5538857-A", -12049, "Hyra");
        TransactionDetail td17 = new TransactionDetail("5500460", new Date(new Date().getTime() - 12 * ONE_DAY_IN_MS),
                new Date(new Date().getTime() - 12 * ONE_DAY_IN_MS), "5538957-A", -300, "Bankomat");

        details.add(td1);
        details.add(td2);
        details.add(td3);
        details.add(td4);
        details.add(td5);
        details.add(td6);
        details.add(td7);
        details.add(td8);
        details.add(td9);
        details.add(td10);
        details.add(td11);
        details.add(td12);
        details.add(td13);
        details.add(td14);
        details.add(td15);
        details.add(td16);
        details.add(td17);

    }

    public static TransactionDetail getDetail(String transactionId) {
        for (TransactionDetail td : details) {
            if (td.getId().equalsIgnoreCase(transactionId)) {
                return td;
            }
        }
        return details.get(0);
    }

}
